package com.sky.controller.admin;

import com.sky.result.Result;
import com.sky.service.WorkspaceService;
import com.sky.vo.BusinessDataVO;
import com.sky.vo.DishOverViewVO;
import com.sky.vo.OrderOverViewVO;
import com.sky.vo.SetmealOverViewVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

@ApiOperation("工作台")
@RestController
@RequestMapping("/admin/workspace")
public class Workspace {
    @Autowired
    private WorkspaceService workspaceService;
    /**
     * 今日营业额
     * @return
     */
    @ApiOperation("工作台")
    @GetMapping("/businessData")
    public Result<BusinessDataVO> businessData() {
        //获取当前是时间
        LocalDate now = LocalDate.now();
        //获取当前时间的最开是00：00：00
        LocalDateTime begin = LocalDateTime.of(now, LocalTime.MIN);
        //获取当前时间的最晚是23：59：59
        LocalDateTime end = LocalDateTime.of(now, LocalTime.MAX);
        BusinessDataVO businessDataVO = workspaceService.getBusinessData(begin, end);
        return Result.success(businessDataVO);
    }
    /**
     * 订单统计接口
     * @return
     */
    @ApiOperation("订单统计接口")
    @GetMapping("/overviewOrders")
    public Result<OrderOverViewVO> overviewOrders() {
        LocalDate now = LocalDate.now();
        LocalDateTime begin = LocalDateTime.of(now, LocalTime.MIN);
        LocalDateTime end = LocalDateTime.of(now, LocalTime.MAX);
        OrderOverViewVO count = workspaceService.getOrdersCount(begin, end);
        return Result.success(count);
    }
    /**
     * 查询菜品总览
     * @return
     */
    @GetMapping("/overviewDishes")
    @ApiOperation("查询菜品总览")
    public Result<DishOverViewVO> dishOverView(){
        return Result.success(workspaceService.getDishOverView());
    }

    /**
     * 查询套餐总览
     * @return
     */
    @GetMapping("/overviewSetmeals")
    @ApiOperation("查询套餐总览")
    public Result<SetmealOverViewVO> setmealOverView(){
        return Result.success(workspaceService.getSetmealOverView());
    }

}
